package com.ruoyi.web.core.netty;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.bytes.ByteArrayEncoder;
import io.netty.handler.codec.string.StringEncoder;

public class ServerChannelInitializer extends ChannelInitializer<SocketChannel> {

  @Override
  protected void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline pipeline = socketChannel.pipeline();
    pipeline.addLast(new HexDecoder());
    pipeline.addLast(new StringEncoder());//添加字符串编码器
    pipeline.addLast(new ByteArrayEncoder());
    pipeline.addLast(new NettyServerHandler());
  }
}
